<template>
  <div>
    <Portlet :title="startAddress ? '出发地信息' : '提货信息'" >
      <el-form label-position="left" label-width="120px">
        <el-col :lg="8" :md="12"  :xl="6">
          <el-form-item label="是否到货：">
            <span>{{ isArriva.text }}</span>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :md="12"  :xl="6">
          <el-form-item label="预计提货：">
            <span>{{ predictDevliveryDate|unixTimestampFilter('YYYY-MM-DD') }}</span>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :md="12"  :xl="6">
          <el-form-item label="提货地址：">
            <span>{{ deliveryProvince }}{{ deliveryCity }}{{ deliveryDistrict }} {{deliveryAddress}}</span>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :md="12"  :xl="6">
          <el-form-item label="提货联系人：">
            <span>{{ deliveryName }}</span>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :md="12"  :xl="6">
          <el-form-item label="提货电话：">
            <span>{{ deliveryPhone }}</span>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :md="12"  :xl="6">
          <el-form-item label="提货备注：">
            <span>{{ deliveryMemo }}</span>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :md="12"  :xl="6" v-if="orderStatus != 'report|300' && orderStatus != 'stayPay|100' && isFhbAdminPath < 0">
          <el-form-item label="历史记录：">
            <a href="javascript:;" @click="consult">查看</a>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :md="12"  :xl="6" v-if="isArriva.value != 2  && isFhbAdminPath < 0">
          <el-form-item label="">
            <el-button type="primary" v-if="(orderStatus == 'service|200' || orderStatus == 'service|550' || orderStatus == 'service|01' || orderStatus == 'service|570')"
                   @click="submit">修改提货信息</el-button>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :md="12"  :xl="6"  v-if="isArriva.value == 2 && isFhbAdminPath < 0 && !jointSourceCodeScm">
          <el-form-item label="">
            <el-button type="primary" @click="submit">到件</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </Portlet>
    <edit-delivery v-if="id" ref="editDelivery" @refresh="refresh" :orderDetail="orderDetail" :id="id"></edit-delivery>
    <address-record ref="addressRecord" :id="id"></address-record>
  </div>
</template>
<script>
import {dotData} from '@/utils'
import {unixTimestampFilter} from '@/filters'
import addressRecord from '@/views/fhb/myOrders/components/modal/AddressRecord'
import editDelivery from '@/views/fhb/myOrders/components/modal/EditDelivery'
export default {
  name: 'takeDelivery',
  components: {
    addressRecord,
    editDelivery
  },
  filters: {
    unixTimestampFilter
  },
  props: {
    orderDetail: {
      type: Object,
      required: true
    },
    startAddress: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      isFhbAdminPath: -1
    }
  },
  computed: {
    isEdit() {
      if (!this.orderDetail.deliveryName || !this.orderDetail.deliveryPhone) {
        return true
      } else {
        return false
      }
    },
    deliveryName() {
      return dotData(this.orderDetail, 'fhbOrderPickupInfo.deliveryName')
    },
    deliveryPhone() {
      return dotData(this.orderDetail, 'fhbOrderPickupInfo.deliveryPhone')
    },
    predictDevliveryDate() {
      return dotData(this.orderDetail, 'fhbOrder.predictDevliveryDate')
    },
    deliveryProvince() {
      return dotData(this.orderDetail, 'fhbOrderPickupInfo.deliveryProvince')
    },
    deliveryCity() {
      return dotData(this.orderDetail, 'fhbOrderPickupInfo.deliveryCity')
    },
    deliveryDistrict() {
      return dotData(this.orderDetail, 'fhbOrderPickupInfo.deliveryDistrict')
    },
    deliveryAddress() {
      return dotData(this.orderDetail, 'fhbOrderPickupInfo.deliveryAddress')
    },
    deliveryMemo() {
      return dotData(this.orderDetail, 'fhbOrderPickupInfo.deliveryMemo')
    },
    id() {
      return dotData(this.orderDetail, 'fhbOrder.id')
    },
    orderStatus() {
      return dotData(this.orderDetail, 'fhbOrder.orderStatus')
    },
    isArriva() {
      if (dotData(this.orderDetail, 'fhbOrder.isArriva') === 1) {
        return {value: 1, text: '是'}
      } else if (dotData(this.orderDetail, 'fhbOrder.isArriva') === 2) {
        return {value: 2, text: '否'}
      } else {
        return {}
      }
    },
    jointSourceCodeScm() { // scm订单
      if (dotData(this.orderDetail, 'fhbOrder.jointSourceCode') === 'scm') {
        return true
      } else {
        return false
      }
    }
  },
  created() {
  },
  methods: {
    submit() {
      // 当前操作的到件还是提货后端自行区分
      this.$refs.editDelivery.show()
    },
    refresh() {
      this.$emit('refresh')
    },
    consult() {
      this.$refs.addressRecord.show()
    }
  }
}
</script>
